//
//  GTVerticalButton.m
//  GiftTalk
//
//  Created by Wan on 16/3/23.
//  Copyright © 2016年 Wan. All rights reserved.
//

#import "GTVerticalButton.h"

@implementation GTVerticalButton

/**
 *  代码创建
 */
- (void)awakeFromNib
{
    [self setup];
}

/**
 *  从storyboard或者xib加载
 */
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setup];
    }
    return self;
}

/**
 *  初始化控件
 */
- (void)setup
{
    self.titleEdgeInsets = UIEdgeInsetsMake(5, 0, 0, 0);
    self.adjustsImageWhenDisabled = NO;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageView.width = self.width * 0.5;
    self.imageView.height = self.width * 0.5;
    self.imageView.centerX = self.width * 0.5;
    self.imageView.y = self.height * 0.1;
    
    self.titleLabel.height = self.height - self.imageView.height - self.titleEdgeInsets.top;
    self.titleLabel.width = self.width;
    self.titleLabel.x = 0;
    self.titleLabel.y = self.imageView.height + self.titleEdgeInsets.top;
    
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
}


@end
